package com.cn.nullframe.controllor;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletRequest;

/**
 * url:http://localhost:8080/nullframe/rest/testInterface/test
 */
@Controller
@RequestMapping("testInterface")
public class TestController {

    private static final ObjectMapper MAPPER = new ObjectMapper();
    @RequestMapping(value = "test", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ResponseBody
    public String test(@RequestBody String json, ServletRequest request) {

        System.out.println("haha");
        try {
            return MAPPER.writeValueAsString("hah");
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return null;
    }

}
